/*
 * @Description:
 * @Author: maskMan
 * @LastEditTime: 2024-11-15 12:04:49
 */
import Cookies from "js-cookie";

// App
const sidebarStatusKey = "sidebar_status";
const expires = 7;
export const getSidebarStatus = () => Cookies.get(sidebarStatusKey);
export const setSidebarStatus = (sidebarStatus: string) =>
  Cookies.set(sidebarStatusKey, sidebarStatus);

// User
const tokenKey = "vue_typescript_admin_access_token";
/**
 * @description: 获取缓存数据
 * @param {string} key
 * @return {*}
 */
export const getItem = (key: string): string => {
  return Cookies.get(key) as string;
};
/**
 * @description: 设置缓存数据
 * @param {string} key key值
 * @param {string} value 值
 * @return {*}
 */
export const setItem = (key: string, value: string) => {
  Cookies.set(key, value, { expires });
};
/**
 * @description: 设置token
 * @param {string} token token
 * @return {*}
 */
export const setToken = (token: string) => {
  Cookies.set(tokenKey, token);
};
/**
 * @description: 获取token
 * @return {*}
 */
export const getToken = (): string => {
  return Cookies.get(tokenKey) as string;
};
/**
 * @description: 清除token
 * @return {*}
 */
export const removeToken = () => {
  Cookies.remove(tokenKey);
};
/**
 * @description: 清除键值
 * @param {*} key
 * @return {*}
 */
export const removeItem = (key) => {
  Cookies.remove(key);
};
